home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1
/
Ian and Stuart's One (Australia).iso
/
Australasian Legends
/
Commercial
/
Rainbow Hill
/
MacDOS™ 2.0.0
/
batches
/
merge.bat
< prev
next >
Wrap
DOS Batch File
|
1993-08-02
|
3KB
|
97 lines
@echo off
! merge.bat merges files with the same name and different extensions
!
! This program accepts extensions as input arguments and merges the files
! into single files with another extension.
!
! Format: MERGE dst src1 src2 src3 src4 src5
!
! Where: dst = extension of the result
! srcN = extensions of the files to be merged
!
! Example: MERGE COMB HEAD BODY TAIL
!
! in a directory containing A.COMB, A.HEAD, A.BODY, BBBODY, C.BODY, C.TAIL
! produces the following files (where '+' indicates concatenation):
!
! A.COMB = A.COMB + A.HEAD + A.BODY
! BBCOMB = BBBODY
! C.COMB = C.BODY + C.TAIL
!
! DOS would have achieved a similar result with the command:
!
! COPY *.HEAD + *.BODY + *.TAIL *.COMB
!
! with the difference that A.COMB would have been replaced by A.HEAD + A.BODY
! rather than by A.COMB + A.HEAD + A.BODY. Also, with DOS you would have not been able to
! pick up BBBODY because it does not have a "dotted" extension.
!
! Note that merge.bat uses INCR and DECR, which are case sensitive, and FOR, which capitalises
! the filenames. Therefore, you must type the extensions in upper case, otherwise INCR and
! DECR will not work.
!
! Copyright © 1993 by Rainbow Hill Pty Ltd. All rights reserved.
!
! the first two arguments are mandatory
if "%1 " == " " goto WRONG_LBL
if " %1" == " /?" goto HELP_LBL
if "%2 " == " " goto WRONG_LBL
onerror ERR_LBL
for %filename in (*%2) do begin
set f=%filename%A
decr f by %2A
incr f by %1A
decr f by 1
copy %filename% %f% /A
next filename
if "%3 " == " " goto DONE_LBL
for %filename in (*%3) do begin
set f=%filename%A
decr f by %3A
incr f by %1A
decr f by 1
copy %filename% %f% /A
next filename
if "%4 " == " " goto DONE_LBL
for %filename in (*%4) do begin
set f=%filename%A
decr f by %4A
incr f by %1A
decr f by 1
copy %filename% %f% /A
next filename
if "%5 " == " " goto DONE_LBL
for %filename in (*%5) do begin
set f=%filename%A
decr f by %5A
incr f by %1A
decr f by 1
copy %filename% %f% /A
next filename
goto DONE_LBL
:WRONG_LBL
echo ***ERROR: less than two arguments.
echo.
:HELP_LBL
echo Merges files with the same name and different extensions
echo.
echo MERGE dst src1 [src2 [src3 [src4 [src5]]]]
echo.
echo dst = extension of the result
echo srcN = extensions of the files to be merged
echo.
goto DONE_LBL
:ERR_LBL
show %doserr%
:DONE_LBL